package com.ruoyi.company.service.impl;

import com.ruoyi.company.domain.CompanyInvoice;
import com.ruoyi.company.mapper.CompanyInvoiceMapper;
import com.ruoyi.company.service.ICompanyInvoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;

/**
 * @author WangChangShuo
 * @date 2022/4/14 14:29
 */

@Service
public class CompanyInvoiceServiceImpl implements ICompanyInvoiceService {

    @Autowired
    CompanyInvoiceMapper companyInvoiceMapper;

    /**
     * 插入公司开票信息
     *
     * @param companyInvoice 需要插入的开票信息
     * @return 结果
     */
    @Override
    @Transactional
    public int insertCompanyInvoice(CompanyInvoice companyInvoice) {
        return companyInvoiceMapper.insertCompanyInvoice(companyInvoice);
    }

    /**
     * 根据公司主键查询开票信息
     *
     * @param companyId 公司主键
     * @return 结果
     */
    @Override
    public CompanyInvoice selectCompanyInvoiceByCompanyId(Long companyId) {
        return companyInvoiceMapper.selectCompanyInvoiceByCompanyId(companyId);
    }

    /**
     * 修改公司开票信息
     *
     * @param companyInvoice 需要修改的开票信息
     * @return 结果
     */
    @Override
    public int updateCompanyInvoice(CompanyInvoice companyInvoice) {
        return companyInvoiceMapper.updateCompanyInvoice(companyInvoice);
    }

    /**
     * 根据公司主键和创建人查询公司开票信息
     *
     * @param map 查询条件
     * @return 结果
     */
    @Override
    public CompanyInvoice selectByCompanyIdAndCreateBy(Map<String, Object> map) {
        return companyInvoiceMapper.selectByCompanyIdAndCreateBy(map);
    }

    /**
     * 根据公司主键查询公司的合作单位发票信息
     *
     * @param companyId 公司主键
     * @return 结果
     */
    @Override
    public CompanyInvoice selectByCompanyId(Long companyId) {
        return companyInvoiceMapper.selectByCompanyId(companyId);
    }

    /**
     * 删除公司开票信息
     *
     * @param hashMap 删除条件
     * @return 结果
     */
    @Override
    public int deleteInvoice(HashMap hashMap) {
        return companyInvoiceMapper.deleteInvoice(hashMap);
    }
}
